package wator.view;

import java.util.Observable;

import wator.view.swing.SwingUI;

/**
 * This is the facade (GoF) of the view package. Classes from other
 * packages should access the user interface only via this interface.
 * Different subclasses may provide a variety of different user
 * interfaces, such as swing, command line, or web interface.
 * 
 * @see #getInstance()
 */
abstract public class UI extends Observable {

	static private UI singleton = new SwingUI();
	
	/**
	 * Get the singleton instance of <code>UI</code>. This is no
	 * lazy singleton pattern implementation, so the singleton is created at
	 * program start in a static way. The user interface can be exchanged by
	 * extending this class and adjust the <code>singleton</code> class
	 * variable. An example implementation is <code>SwingUI</code>.
	 *  
	 * @return the singleton instance of <code>UI</code>
	 * @see wator.view.swing.SwingUI
	 */
	static public UI getInstance() {
		return singleton;
	}
	
	/**
	 * Initializes the UI. This is called after the simulation is initialized.
	 * Implementing subclasses may register observer relationships to the
	 * model here, but should not display the actual user interface.
	 * 
	 * @see wator.model.Simulation
	 */
	abstract public void initialize();
	
	/**
	 * Display the user interface. All singletons in the model are initialized.
	 * At this state, an empty population exists and the topology is set to its
	 * default configuration. 
	 */
	abstract public void show();
}
